<?php
/**
 * Created by PhpStorm.
 * User: hao
 * Date: 2018/11/1
 * Time: 4:46 PM
 */

namespace app\api\controller\v1;


use app\api\controller\BaseController;
use app\api\service\WxNotify;
use app\api\validate\IDMustBePostiveInt;
use \app\api\service\Pay as PayService;

class Pay extends BaseController
{
    protected $beforeActionList = [
        'checkExclusiveScope' => ['only' => 'getPreOrder']
    ];

    public function getPreOrder($id=''){
        (new IDMustBePostiveInt())->goCheck();
        $pay = new PayService($id);
        return $pay->pay();
    }

    public function redirectNotify()
    {
        $notify = new WxNotify();
        $notify->handle();
    }

    public function receiveNotify(){
        //通知频率为15、15、30、180、1800、1800....单位：秒
        //1，检查库存量，
        //2，更新这个订单的status
        //3，减去库存量
        //如果成功处理，我们返回微信成功处理的信息，反之，我们返回没有成功处理；

        //特点：post：xml格式，不会携带参数
        $notify = new WxNotify();
        $notify->handle();
    }
}